package com.example.demo07cache.controller;

import com.example.demo07cache.component.RedisLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangxun
 */
@RestController
@RequestMapping("/redis")
public class RedisDecrController {

    @Autowired
    private RedisLock redisLock;

    @GetMapping("/decrToZero")
    public boolean decrToZero() {
        return redisLock.decrToZero("stock:001");
    }


    @GetMapping("/decrStock")
    public boolean decrStock() {
        return redisLock.decrStock("stock:001", 5);
    }
}
